#include <stdio.h>
#include <stdlib.h>

bool rankHasRoot(const int rank, const int nRanks, const int nIds) {
    const int rmr  = nRanks % nIds;
    const int rpr  = nRanks / nIds;
    const int rlim = rmr * (rpr+1);

    if (rank < rlim) {
        return !(rank % (rpr + 1));
    } else {
        return !((rank - rlim) % rpr);
    }
}

int main() {
    int nRanks = 7;
    int nIds   = 3;

    for (int rank = 0; rank < nRanks; ++rank) {
        printf("Rank %d has root: %s\n", rank, rankHasRoot(rank, nRanks, nIds) ? "Yes" : "No");
    }

    return 0;
}

